<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 需要注意的是构造函数的中原来是没有extends这个关键字的，所以不能直接继承
    // 他想要实现继承就需要借助一些其他的方式，参看继承这个文件夹
    function Person(theName, theAge, theSex, theHobby) {
      this.name = theName;
      this.age = theAge;
      this.sex = theSex;
      this.hobby = theHobby
      this.speak = function () {
        console.log("说话");
      }
    }
    // var per1 = new Person('小黑',18,'女','研发')
    // var per2 = new Person('小白',28,'男','运动')
    // var per3 = new Person('小明',17,'男','学习')
    // console.log(per1, per2, per3);
    // console.log(Person)
    Person.prototype.sing = function () {
      console.log('学习唱歌');
    }
    // prototype属性只有构造函数才有，普通对象是没有的，p1是实例化的对象，它上面是没有这个属性的
    // console.log(Person.prototype)
    var p1 = new Person()
    console.log(p1.__proto__);
    // console.log(Object.getPrototypeOf(p1));
    // console.log(p1.__proto__ === Person.prototype);
    p1.speak()
    p1.sing()
    var p2 = new Person()
    console.log(p1.sing === p2.sing)
  </script>
</body>

</html>